home *** CD-ROM | disk | FTP | other *** search
/ Oh!X 2001 Spring / Oh!X 2001 Spring Special CD-ROM (Japan).7z / Oh!X 2001 Spring Special CD-ROM (Japan) (Track 1).bin / GALAXY / ohx5-1 / inettest.cpp < prev    next >
C/C++ Source or Header  |  2000-05-28  |  767b  |  34 lines

  1. // inettest.cpp
  2. #include <stdio.h>
  3. #include <windows.h>
  4. #include <wininet.h>
  5.  
  6. #pragma comment(lib, "wininet.lib")
  7.  
  8. int main(int argc, char* argv[])
  9. {
  10.     HINTERNET hInternet = InternetOpen("Agent", 0, NULL, NULL, 0);
  11.     HINTERNET hFile = InternetOpenUrl(hInternet, argv[1], NULL, NULL, 0, 0);
  12.     if (hFile == NULL)
  13.     {
  14.         fprintf(stderr, "file not found: %s", argv[1]);
  15.         InternetCloseHandle(hInternet);
  16.         return 1;
  17.     }
  18.  
  19.     char c;
  20.     DWORD dwBytesToRead;
  21.     for (;;)
  22.     {
  23.         if (!InternetReadFile(hFile, &c, 1, &dwBytesToRead))
  24.             break;
  25. if (dwBytesToRead != 1)
  26.             break;
  27.         putchar(c);
  28.     }
  29.     InternetCloseHandle(hFile);
  30.     InternetCloseHandle(hInternet);
  31.     return 0;
  32. }
  33.  
  34.